<?php
/**
* エラーチェッククラス
**/
require_once( '../system/Class_M_DAO.php' );
class t_m_goods extends Class_M_DAO {
	
	//protected properties begin
	/**
	 *
	 * テーブル名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_table = "D_GOODS";
	
	/**
	 *
	 * 主キー名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_pkey = "id";
	
	/**
	 *
	 * ソート順
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	 protected $_order = "id";
	 
	 protected $_cols  = array(
       "site_id" => array(ECJP_VARTYPE_INT),           // 'サイトID',
       "goods_id" => array(ECJP_VARTYPE_INT),          // '商品コード',
  "goods_name" => array(ECJP_VARTYPE_STR),             // '商品名',
  "goods_type" => array(ECJP_VARTYPE_STR),             // '商品種別',
  "category_id" => array(ECJP_VARTYPE_INT),            // 'カテゴリ',
  "goods_unitprice" => array(ECJP_VARTYPE_STR),        // '本体価格',
  "goods_sale" => array(ECJP_VARTYPE_STR),             //'特別価格',
  "goods_stockstatus" => array(ECJP_VARTYPE_STR),      // '在庫',
  "goods_image" => array(ECJP_VARTYPE_STR),            // '商品画像',
  "goods_issuedate" => array(ECJP_VARTYPE_DATE),        //  '発行月',
  "goods_style" => array(ECJP_VARTYPE_STR),            // '仕様',
  "goods_mark1" => array(ECJP_VARTYPE_STR),            // 'フラグ',
  "goods_mark2" => array(ECJP_VARTYPE_STR),            // 'フラグ',
  "goods_unit" => array(ECJP_VARTYPE_INT),             // '単位',
  "goods_slogan" => array(ECJP_VARTYPE_STR),           // 'キャッチコピー',
  "goods_order" => array(ECJP_VARTYPE_INT),            //'表示順',
  "goods_status" => array(ECJP_VARTYPE_STR),           // '状態',
  "metadescription" => array(ECJP_VARTYPE_STR),        //  'META Description',
  "metakeyword" => array(ECJP_VARTYPE_STR),            // 'META Keyword',
  "tryURL" => array(ECJP_VARTYPE_STR),                 //'試し読みURL',
  "outsideURL" => array(ECJP_VARTYPE_STR),             // '外部URL',
  "insideappraise" => array(ECJP_VARTYPE_STR),         // '社内コメント',
  "sellbegin" => array(ECJP_VARTYPE_DATE),              //'販売開始日時',
  "sellend" => array(ECJP_VARTYPE_DATE),                //'販売終了日時',
  "freespace1" => array(ECJP_VARTYPE_STR),             //'フリースペース1',
  "freespace2" => array(ECJP_VARTYPE_STR),             //'フリースペース2',
  "freespace3" => array(ECJP_VARTYPE_STR),             //'フリースペース3',
  "c_time" => array(ECJP_VARTYPE_DATE),                 //'新規日時',
  "u_time" => array(ECJP_VARTYPE_DATE),                 //'更新日時',
  "c_user" => array(ECJP_VARTYPE_INT),                 //'新規者名',
  "u_user" => array(ECJP_VARTYPE_INT),                 // '更新者名',
	 );
/*
define("CHK_EXIST",     1);
define("CHK_NUM",       2);
define("CHK_LEN",       3);
define("CHK_MAX",       4);
define("CHK_ALNUM",     5);//半角英数チェック 
define("CHK_TEL",       6);
define("CHK_EMAIL",     7);
define("CHK_URL",       8);
define("CHK_KATAKANA",  9);
define("CHK_HIRAKANA",  10);
define("CHK_YMD",       11);
define("CHK_PLATFORM",  12);//機種依存文字チェック
define("CHK_ZIP",       13);
 */
	 protected $_checks  = array(
 			// "site_id" 	=>	array( CHK_EXIST ,CHK_NUM ),
 			 "goods_id" 	=>	array( CHK_EXIST ,CHK_NUM ),
 			 "goods_name" 	=>	array( CHK_EXIST ,CHK_PLATFORM ),
 			 "goods_type" 	=>	array( CHK_EXIST ,CHK_PLATFORM ),
 			 "category_id" 	=>	array( CHK_PLATFORM ),
 			 "goods_unitprice" 	=>	array( CHK_EXIST ,CHK_PLATFORM ),
 				"goods_stockstatus" 	=>	array( CHK_EXIST ,CHK_PLATFORM ),
 			 "goods_image" 	=>	array(CHK_EXIST,CHK_PLATFORM ),
 			 "goods_issuedate" 	=>	array( CHK_EXIST ,CHK_YMD),
 			 "goods_style" 	=>	array( CHK_EXIST ,CHK_PLATFORM ),
 			 "goods_mark1" 	=>	array( CHK_NUM ),
 			 "goods_mark2" 	=>	array( CHK_NUM ),
 			 "goods_unit" 	=>	array( CHK_EXIST ,CHK_NUM ),
 			 "goods_slogan" 	=>	array( CHK_EXIST ,CHK_PLATFORM ),
 			"goods_status" 	=>	array( CHK_EXIST ,CHK_PLATFORM ),
 			 "metadescription" 	=>	array( CHK_EXIST ,CHK_PLATFORM ),
			 "metakeyword" 	=>	array( CHK_EXIST ,CHK_PLATFORM ),
			 "tryURL" 	=>	array( CHK_URL ),
			 "outsideURL" 	=>	array( CHK_URL ),
	 		"insideappraise" 	=>	array( CHK_PLATFORM ),
	 		"sellbegin" 	=>	array( CHK_PLATFORM ),
	 		"sellend" 	=>	array( CHK_PLATFORM ),
	 		"freespace1" 	=>	array( CHK_PLATFORM ),
	 		"freespace2" 	=>	array( CHK_PLATFORM ),
	 		"freespace3" 	=>	array( CHK_PLATFORM ),
 			
	 
	 );
	 
	 
	 public function search($where='' ,&$page = NULL ){	
		$sql = "SELECT *  FROM d_goods a ";
		$sqlcnt = "SELECT COUNT(*) AS cnt FROM d_goods a ";
		return  parent::search($where ,$page ,$sql,$sqlcnt,"a.c_time desc");
	}

	
	 public function search_csv($where){	
	    $sql = "SELECT *  FROM d_goods a ";
		$page = null;
		return  parent::search($where ,$page ,$sql);
	}
	
}

?>
